package com.ruoyi.exam.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.exam.domain.ExamMakeupStudent;
import com.ruoyi.exam.service.IExamMakeupStudentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 补缓考学生关联管理Controller
 * 
 * @author ruoyi
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/exam/makeupStudent")
public class ExamMakeupStudentController extends BaseController
{
    @Autowired
    private IExamMakeupStudentService examMakeupStudentService;

    /**
     * 查询补缓考学生关联管理列表
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupStudent:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExamMakeupStudent examMakeupStudent)
    {
        startPage();
        List<ExamMakeupStudent> list = examMakeupStudentService.selectExamMakeupStudentList(examMakeupStudent);
        return getDataTable(list);
    }

    /**
     * 导出补缓考学生关联管理列表
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupStudent:export')")
    @Log(title = "补缓考学生关联管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExamMakeupStudent examMakeupStudent)
    {
        List<ExamMakeupStudent> list = examMakeupStudentService.selectExamMakeupStudentList(examMakeupStudent);
        ExcelUtil<ExamMakeupStudent> util = new ExcelUtil<ExamMakeupStudent>(ExamMakeupStudent.class);
        util.exportExcel(response, list, "补缓考学生关联管理数据");
    }

    /**
     * 获取补缓考学生关联管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupStudent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(examMakeupStudentService.selectExamMakeupStudentById(id));
    }

    /**
     * 新增补缓考学生关联管理
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupStudent:add')")
    @Log(title = "补缓考学生关联管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamMakeupStudent examMakeupStudent)
    {
        return toAjax(examMakeupStudentService.insertExamMakeupStudent(examMakeupStudent));
    }

    /**
     * 修改补缓考学生关联管理
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupStudent:edit')")
    @Log(title = "补缓考学生关联管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExamMakeupStudent examMakeupStudent)
    {
        return toAjax(examMakeupStudentService.updateExamMakeupStudent(examMakeupStudent));
    }

    /**
     * 删除补缓考学生关联管理
     */
    @PreAuthorize("@ss.hasPermi('exam:makeupStudent:remove')")
    @Log(title = "补缓考学生关联管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(examMakeupStudentService.deleteExamMakeupStudentByIds(ids));
    }
}
